
//final修饰类，这个类就不能被继承了
final class A {
    //public final int n;//编译报错 final修饰成员变量必须给个初值
    public final int n = 1;

    //final 修饰方法，该方法就不能被重写
    public final void test() {
        System.out.println("A");
    }

    A() {
        System.out.print("Base");
    }
}

//class B extends A {
////    public void test() {
////        System.out.println("B");
////    }
//}


public class Test3 {
    public static void main(String[] args) {
        int a = 10;
        a = 100;
        final int b = 10;
        //b = 100;//编译报错 final修饰局部变量，该变量的值就不能修改了
        final int[] array = {1,2,3};
        array[0] = 100;
        //array = new int[3];//编译报错 array不能指向别的对象
    }
}


